import matplotlib.pyplot as plt
import random
from collections import Counter

if __name__ == "__main__":

    # 散点图 scatter plot
    # random.seed(666)
    # x = [random.randint(0,100) for _ in range(100)]
    # y = [random.randint(0,100) for _ in range(100)]
    # plt.scatter(x,y)
    # plt.show()

    # 折线图 line plot
    # x = [random.randint(0,100) for _ in range(100)]
    # plt.plot([i for i in range(100)],x)
    # plt.show()

    # 条型图 bar plot 分类变量
    # data = [1,2,3,2,2,2,1,2,3,4,4,4,4,6,6,6,6,5,5,5,7,5,8,8,9,9,10]
    # counter = Counter(data)
    # x = [point[0] for point in counter.most_common()]
    # y = [point[1] for point in counter.most_common()]
    # plt.bar(x,y)
    # plt.show()

    # 直方图 histogram 数值变量
    # data = [random.randint(1,100) for _ in range(1000)]

    # plt.hist(data,rwidth=0.8,bins=5,density=True)
    # plt.show()

    #箱线图 boxplot
    data = [random.randint(1,100) for _ in range(1000)]
    #极端值
    data.append(-200)
    data.append(200)
    plt.boxplot(data)
    plt.show()


    #并排箱线图
    data1 = [random.randint(66,100) for _ in range(1000)]
    data2 = [random.randint(88,150) for _ in range(1000)]
    plt.boxplot([data1,data2])
    plt.show()




